<?php require_once('Connections/congress.php'); ?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

$errors = array();

if (isset($_POST['user'])) {
  $loginUsername=$_POST['user'];
  $password=$_POST['pass'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "abstract_proceeding_list.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_congress, $congress);
  
  $LoginRS__query=sprintf("SELECT USER_NAME, PASS FROM user WHERE USER_NAME='%s' AND PASS='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $congress) or die(mysql_error());
  $user = mysql_fetch_assoc($LoginRS);
  $loginFoundUser = mysql_num_rows($LoginRS);
  echo $LoginRS['PASS'];
  if ($loginFoundUser && $user['PASS'] == $password) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
	array_push($errors, "Username or Password are invalid.");
  }
}
?>
<?php

	include('functions.php');
	
	$bgcolor = "#229CBA";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

	<title>CONGRESS ADMIN - LOGIN</title>

	<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
	<link href="accordion/style.css" rel="stylesheet" type="text/css" media="screen" />

	<script src="accordion/accordian.pack.js" language="javascript" type="text/javascript">
	</script>

	<style>
		body {
			padding: 0px;
			margin: 0px;
		}
		
		.bodybg {
			background: <?php echo $bgcolor; ?>
			filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='<?php echo $bgcolor; ?>', endColorstr='#FFFFFF');
			background: -webkit-gradient(linear, left top, left bottom, from(<?php echo $bgcolor; ?>), to(#FFFFFF));
			background: -moz-linear-gradient(top,  <?php echo $bgcolor ?>,  #FFFFFF);
			width:100%;
			height: 600px;
		}
	</style>

	<script type="text/javascript" src="jscolor/jscolor.js"></script>

</head>

<body>

	<div align="center" class="bodybg">

		<?php include('admin_header.php'); ?>

		<div style="width: 870px; background-color: #B6D490; padding: 5px;" align="left">
			LOGIN
		</div>

		
	  <div id="basic-accordian" style="background-color: white;">
		    
			<?php if (sizeof($errors) > 0) { include('errors.php'); } ?>
			
			<form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" name="login_form">
              <table align="center" cellpadding="5">
				<tr>
					<td>User</td>
					<td><input type="text" name="user" />
				</tr>
				<tr>
					<td>Password</td>
					<td><input type="password" name="pass" />
				</tr>


				<tr>
					<td align="center" colspan="2">
						<input type="submit" value="Login" />
					</td>
				</tr>

              </table>
        </form>
            <p>&nbsp;</p>
	  </div>
		
	</div>

</body>
</html>
